﻿
//键值对包含 Remover方法
function RemoveArray(array, attachId) {
    for (var i = 0, n = 0; i < array.length; i++) {
        if (array[i] != attachId) {
            array[n++] = array[i]
        }
    }
    array.length -= 1;
}
Array.prototype.remove = function (obj) {
    return RemoveArray(this, obj);
};
//自定义键值对类
function Dictionary() {
    this.keys = new Array();
    /** 存放数据 */
    this.data = new Object();
    /**  
    * 放入一个键值对  
    * @param {String} key  
    * @param {Object} value  
    */
    this.put = function (key, value) {
        if (this.data[key] == null) {
            this.keys.push(key);
        }
        this.data[key] = value;
    };

    /**  
    * 获取某键对应的值  
    * @param {String} key  
    * @return {Object} value  
    */
    this.get = function (key) {
        return this.data[key];
    };

    /**  
    * 删除一个键值对  
    * @param {String} key  
    */
    this.remove = function (key) {
        this.keys.remove(key);
        this.data[key] = null;
    };
    /**  
    * 获取键值数组(类似Java的entrySet())  
    * @return 键值对象{key,value}的数组  
    */
    this.entrys = function () {
        var len = this.keys.length;
        var entrys = new Array(len);
        var KeyValue;
        var varValue;
        for (var i = 0; i < len; i++) {
            KeyValue = this.keys[i];
            entrys[i] = {
                key: KeyValue,
                value: this.data[KeyValue]
            };
        }
        return entrys;
    };

    /**  
    * 判断Map是否为空  
    */
    this.isEmpty = function () {
        return this.keys.length == 0;
    };

    /**  
    * 获取键值对数量  
    */
    this.size = function () {
        return this.keys.length;
    };
}

var d = new Dictionary();    //保存查询条件
var isChangeURL = "yes";
//关闭弹出层
function CloseDiv() {
    $.unblockUI();
    isFistPlay = "no";
    var varViewClose = $(".view");
    // varViewClose.css("padding-top", '50px');
    // varViewClose.css("padding-left", '170px');
    // varViewClose.css("padding-right", '170px');
}

//设置图片文件属性
function SetUpPhoto() {
    var Fileid = document.getElementById("hidUrl").value;
    var Swidth = (window.screen.width - 880) / 2;
    var Sheight = (window.screen.height - 600) / 2;
    window.open("../Progect/PhotoManage/PhotoProject.aspx?id=" + Fileid + "&Type=1", "", "top=" + Sheight + "px,left=" + Swidth + "px,height=600px,width=880px,scrollbars=yes");
}

//设备视频文件属性
function SetUpVideo() {
    var Fileid = document.getElementById("hidUrl").value;
    var Swidth = (window.screen.width - 880) / 2;
    var Sheight = (window.screen.height - 600) / 2;
    window.open("../Progect/PhotoManage/VideoProject.aspx?id=" + Fileid + "&Type=1", "", "top=" + Sheight + "px,left=" + Swidth + "px,height=600px,width=880px,scrollbars=yes");
}

//删除图片
function DeletePhoto() {
    var theResponse = window.prompt("确认删除该图片文件？删除后不可恢复！", "请您在此输入密码：");
    if (theResponse == "请您在此输入密码：" || theResponse == null) {
        return;
    }
    if (theResponse.length != 8) {
        alert("请您重新输入密码！");
        return;
    }
    else {
        var Fileid = document.getElementById("hidUrl").value;
        HQWeb.Progect.PhotoManage.PhotoServer.DeleteFile(Fileid, theResponse, '0', SucceedOut, failedOut);
    }
}


//删除视频
function DeleteVideo() {
    var theResponse = window.prompt("确认删除该视频文件？删除后不可恢复！", "请您在此输入密码：");
    if (theResponse == null || theResponse == "请您在此输入密码：") {
        return;
    }
    if (theResponse.length != 8) {
        alert("请您重新输入密码！");
        return;
    }
    else {
        var Fileid = document.getElementById("hidUrl").value;
        HQWeb.Progect.PhotoManage.PhotoServer.DeleteFile(Fileid, theResponse, '1', SucceedOut, failedOut);
    }
}

//隐藏图片
function HiddenPhoto() {
    if (window.confirm('是否确认隐藏图片？')) {
        var Fileid = document.getElementById("hidUrl").value;
        HQWeb.Progect.PhotoManage.PhotoServer.HiddenFile(Fileid, SucceedOut, failedOut);
        //alert("是否隐藏图片？");
    } else {
        return;
    }
    //alert("是否隐藏图片？");
}


//隐藏视频
function HiddenVideo() {
    if (window.confirm('是否确认隐藏视频？')) {
        var Fileid = document.getElementById("hidUrl").value;
        HQWeb.Progect.PhotoManage.PhotoServer.HiddenFile(Fileid, SucceedOut, failedOut);
        //alert("是否隐藏视频？");
    } else {
        return;
    }
}

//保存返回结果
function SucceedOut(resout) {
    if (resout == "") {
        alert("操作成功！");
        CloseDiv();
        getNextPage(0);
    } else {
        if (resout == "SessionTimeout") {
            IsReLogin();
        } else {
            alert(resout);
        }
    }
}

//客户端异常处理
function failedOut(error) {
    alert(error.get_message());
}

//获得用ajax 调用后台方法获取图片项目
function getFile() {
    var Fileid = document.getElementById("hidUrl").value;
    var varTypeID = $("#hidID").val();      //模块ID
    if ($("#hidRunState").val() == '1') {
        funMessage();
    } else {
        $("#hidRunState").val('1');
        if (varTypeID != "6") {
            $.ajaxSetup({
                cache: false //关闭AJAX相应的缓存
            });
            var url = "GetProject.ashx?id=" + Fileid + "&type=" + varTypeID;
            // $.get(url, getProject, "json");
            $.ajax({
                cache: "False",
                type: "GET",
                async: false,
                url: url,
                success: getProject,
                error: function (xhr, ajaxOptions, thrownError)
                { alert("网络异常，稍后重试！"); $("#hidRunState").val('0'); return false; }
            });

        } else {            //主题婚礼
            getProject("");
        }
    }
}
// 得到文件项目
function getProject(obj) {
    if (obj == "SessionTimeout") {
        IsReLogin();
    }
    else {
        document.getElementById("project").innerHTML = "";
        document.getElementById("vproject").innerHTML = "";
        var projectDiv;
        if (fileType == "-1") {
            projectDiv = $("#vproject")
        } else {
            projectDiv = $("#project")
        }
        if (obj != "") {
            $.each(obj, function (key, value) {
                var GetCValue = getCookieValue("shopcar");
                // alert(GetCValue);
                var VarID = "a" + key;
                if (GetCValue.indexOf(key + "|") == -1) {  //不存在

                    projectDiv.append(" <li><a href=\"javascript:void(0)\" id=" + VarID + " onclick=\"getProjectInfo('" + VarID + "','" + key + "','1')\">" + value + "</a>数量:<input type=\"text\" id=\"txt" + key + "\" value=\"1\" onblur=\"checkIsInt(this)\"/> <input type=\"button\" value=\"确定\"  id=\"btn" + key + "\" onclick=\"EditShopCarValue('" + key + "')\"/> ");


                } else {

                    projectDiv.append(" <li><a href=\"javascript:void(0)\" id=" + VarID + " onclick=\"getProjectInfo('" + VarID + "','" + key + "','1')\">" + value + "</a>数量:<input type=\"text\" id=\"txt" + key + "\" value=\"" + GetCount(key) + "\" onblur=\"checkIsInt(this)\" /> <input type=\"button\" value=\"修改\"  id=\"btn" + key + "\" onclick=\"EditShopCarValue('" + key + "')\"/> ");

                }
            })
        } else {   //特色婚礼
            projectDiv.append(ThemeVale);
        }
        $("#hidRunState").val('0');
    }
}
//页面加载后得到所有文件路径
function GetUrl() {
    if (document.getElementById("myGallery") == null) {
        //if (varGallery != null && varGallery!=undefined) {
        $(".gv_panel").remove();
        $(".gv_filmstrip").children().remove();
        varGallery.storeImages();
        varGallery.buildGallery();
        varGallery.initImages();
        varGallery.bindActions();
    } else {
        var varHtml = "";
        var varUrlArry = document.getElementById("hidPhotoUrl").value.split(",");
        var varIP = document.getElementById("hidIP").value + "/";
        for (var i = 0; i < varUrlArry.length; i++) {
            if (varUrlArry[i] != "") {

                varHtml += "<li><img src=\"" + "ftp://" + varIP + CheckFileName(varUrlArry[i]) + "\"  /></li>";
            }
        }
        document.getElementById("myGallery").innerHTML = varHtml;
    }
    isChangeURL = "no";
}
var fileType;
var varGallery;

//名称去除第一个‘/’
function CheckFileName(FName) {
    if (FName.substr(0, 1) == "/") {
        return FName.substr(1);
    } else {
        return FName;
    }
}

//点击页面缩略图弹出图片或者视频 i=-1表示视频其他表示图片位置
function GetView(i, videoUrl, vieoPhoto) {

    var varWindowWith;
    var height;

    // 支持(mozilla/netscape/opera/chrome/IE7) 

    if (typeof window.innerWidth != 'undefined') {
        varWindowWith = window.innerWidth;
        height = window.innerHeight;
    }   // 支持其他浏览器
    else {
        varWindowWith = document.getElementsByTagName('body')[0].clientWidth;
        height = document.getElementsByTagName('body')[0].clientHeight;
    }
    var leftWith = varWindowWith * (1 / 6);

    var varTop = 0;
    fileType = i;

    var width = varWindowWith * (2 / 3);
    //var height = document.documentElement.cl;
    //alert(height);

    var vheight = width * (9 / 16) + height * (136 / 1080);
    var maxHeighe = height - height * (224 / 1080) - 90
    var play_height;
    if (vheight > maxHeighe) {
        vheight = maxHeighe;
        width = maxHeighe * (16 / 9);
        play_height = maxHeighe - 50;
        leftWith = (varWindowWith - width) / 2;
    } else {
        vheight = width * (9 / 16)
        play_height = vheight;
    }
    // alert(vheight);
    if (i != "-1") {
        if (isChangeURL == "yes") {
            GetUrl();
        }
        if (document.getElementById("myGallery") != null) {
            // if (varGallery != null && varGallery != undefined) {
            varGallery = $('#myGallery').galleryView({ panel_width: width, panel_height: vheight, frame_width: (varWindowWith * 197 / 1920), frame_height: (height * 116 / 1080), frame_gap: 7, frame_opacity: 0.32 });
        }
        else {
            varGallery.showItem(i);
            if ($(".gv_panel").size() == 2) {
                $(".gv_panel").eq(0).remove();
            }
        }


    } else {
        var varIP = "ftp://" + $("#hidIP").val() + "/" + CheckFileName(videoUrl);

        if (isFistPlay != "yes") {

            var start = videoUrl.lastIndexOf("/");
            var end = videoUrl.lastIndexOf(".");
            var filevalue = videoUrl.substring(start + 1, end);
            $('#hidUrl').attr('value', filevalue);
            getFile();
        }
        //alert(isFistPlay);
        // if (isFistPlay != "yes") {

        //  $("#view").css("padding-left", "100px");
        // $("#view").css("padding-left", "170px");
        // $("#view").css("padding-right", "200px");
        // }
        var varphoto = "http://s1-www.ltvimg.com/v3_5_5/images/jw-player/lWMJeVvV-720.jpg";
        jwplayer("player1").setup({
            skin: "../../Scripts/view/glow.zip",
            stretching: "fill",
            flashplayer: "../../Scripts/view/player.swf",
            image: varphoto,
            width: (isFistPlay == "yes" ? $(window).width() : width),
            height: (isFistPlay == "yes" ? $(window).height() - 40 : play_height),
            autostart: true,
            kenburns: (isFistPlay == "yes" ? true : false),
            showvolume: true,
            controlbar: "over",
            allowfullscreen: true,
            fullscreen: true,
            fsbuttonlink: "javascript:CloseDiv();",
            levels: [
                                   { file: varIP }
                                    ],
            events: {
                onComplete: function (event) {
                    if (isFistPlay == "yes") {
                        CloseDiv();
                        isFistPlay = "no";
                    }
                }
            }
        });
    }
    // }

    if (i != "-1") {

        $.blockUI({    //当点击事件发生时调用弹出层
            message: $('#photoview'),    //要弹出的元素box
            css: {    //弹出元素的CSS属性
                top: '0px',
                left: '0px',
                draggable: true,
                //   textAlign: 'center',
                //  width: '700px',
                background: 'none'

            }
        });

        $("#photoview").css("padding-left", leftWith);
        $("#photoview").css("padding-right", leftWith);
        $("#photoview").css("top", varTop);
        // alert($(".class_view").get(0).offsetHeight);
        //  $('#view').css("top", varTop);
        $(".vtb").css("height", ($(".gv_galleryWrap").height()+14));
        $(".classCloseWindow").css("top", (varTop + 40));
        //$(".classCloseWindow").css("top", (document.getElementById("")..offset().top + varTop + 7));
        $(".classCloseWindow").css("left", ($(".gv_galleryWrap").width() + leftWith-5));
        //        var varObj = $(".gv_thumbnail img");
        //        for (var i = 0; i < varObj.length; i++) {
        //            varObj[i].insetBorder(); 
        //        }
        setTimeout(fb, 1500)

        // varObj.each(function () { $(this).insetBorder(); });
        // $(".projectcss").css("top", $(".gv_galleryWrap").height() + varTop);
        //$(".gv_filmstrip").css("left", "0px");
    } else {
        // $("#player1_wrapper").css("float", "left");
        $("#view").css("padding-left", leftWith);
        $("#view").css("padding-right", leftWith);
        // $("#photoview").css("top", varTop);
        // alert($(".class_view").get(0).offsetHeight);
        varTop = 20;
        $('#view').css("top", varTop);
        // $(".classCloseWindow").css("top", ($("#player1_wrapper").offset().top - 7));
        //player1
        $(".classCloseWindow").css("top", (varTop + 40));
        $(".classCloseWindow").css("left", ($("#player1_wrapper").width() + leftWith - 15));
        $(".vtb").css("height", $("#player1_wrapper").height());
        $.blockUI({    //当点击事件发生时调用弹出层
            message: $('#view'),    //要弹出的元素box
            css: {    //弹出元素的CSS属性
                top: '0px',
                left: '0px',
                textAlign: 'center',
                background: 'none',
                width: (isFistPlay == "yes" ? $(window).width() : "auto"),
                height: (isFistPlay == "yes" ? $(window).height() : "auto")
            }
        });
       

    }

}
function fb() {
    $(".gv_thumbnail img").each(function () { createPosation("", $(this)); })
}
//下一页
function getNextPage(obj) {

    var varCount = $("#Photocount").val();
    var Indexs = $("#PageIndex").val();
    var projectType = $("#HIdProjectType").val();
    var Index = parseInt(Indexs, 10) + parseInt(obj, 10);
    var NewCount = parseInt(Index) * 16;
    var str = "";
    var tt = d.entrys();
    for (var i = 0; i < tt.length; i++) {
        str = tt[i].key + "|" + tt[i].value + "," + str;
    }
    var url = "GetFile.ashx";

    var flag = NewCount < (parseInt(varCount, 10) + 16);
    if (NewCount > 0 && flag) {
        var PostData = { type: $("#hidID").val(), num: Index, Where: str, projecttype: projectType };
        $.ajax({
            cache: "False",
            type: "POST",
            async: false,
            url: url,
            data: PostData,
            success: SetProgect,
            error: function (xhr, ajaxOptions, thrownError)
            { alert("网络异常，稍后重试！"); return false; }
        });
        $("#PageIndex").val(Index);
        var intHtml = varCount + "记录   当前第" + Index + "页";
        $("#count").html(intHtml);
        isChangeURL = "yes"
        // GetUrl();
    }
}
//项目填充
function SetProgect(obj) {

    if (obj == "SessionTimeout") {
        IsReLogin();
    }
    else {
        var varHtml = obj[1];
        $("#countList").html(varHtml);
        $("#hidPhotoUrl").val(obj[2]);
    }

}
//查询函数
function getSearchDate(key, value, obj) {
    $("#PageIndex").val("0")
    document.getElementById("PageIndex").value = "0";
    if (d.get(key) != null && d.get(key) != undefined) {
        if (d.get(key) == value) {
            if (obj != undefined && obj != null) {   //排除按照名称查询
                d.remove(key);
                obj.style.backgroundImage = "";
            }
        } else {
            $($(obj).siblings()).css("backgroundImage", "");
            d.remove(key);
            d.put(key, value);
            $(obj).css("backgroundImage", "url(" + "../../Images/View/sure.png)");
        }
    } else {
        d.put(key, value);
        if (obj != undefined && obj != null) {
            obj.style.backgroundImage = "url(" + "../../Images/View/sure.png)";
        }

    }
    getNextPage('1');
}

function CleanSearch() {
    while (!d.isEmpty()) {
        d.remove(d.keys[0]);
    }
    $("a").css("backgroundImage", "");
    getNextPage('0');
}


var isView = 0;
//显示订单
function openOrder() {
    // $(".order").load("OrderEdit.aspx");
    if ($("#hidRunState").val() == '1') {
        funMessage();
    } else {
        //alert(isView);
        if (isView == 0) {
            $("#hidRunState").val('1');
            __doPostBack('GetProject', '');
            //document.getElementById("GetProject").click();
            isView = 1;


        } else {
            isView = 0;
        }
        $('.orderPage').slideToggle("normal", FillStyle).animate({ marginTop: "25px" }, 250, function () {  //回调函数控制   
            $(".orderPage").animate({ marginTop: "-25px" }, 250);
        });
        //IsRuning = '0';
    }
}
//订单隐藏
function CloseOrder() {
    if ($("#hidRunState").val() == '1') {
        funMessage();
    } else {
        $('.orderPage').slideUp();
        isView = 0;
    }
}
//缩放功能
function expandcollapse(obj, row) {
    var div = document.getElementById(obj);
    var img = document.getElementById(row);
    if (div.style.display == "none") {
        div.style.display = "";
        if (img != null) {
            img.src = "../../Images/more.gif";
            img.alt = "关闭显示";
        }

    }
    else {
        div.style.display = "none";
        if (img != null) {
            img.src = "../../Images/more.gif";
            img.alt = "显示下级菜单";
        }
    }
}
//金额输入判断
function CheckMessage(obj) {
    var varId = obj.id;
    var varValue = obj.value;
    var reDouble = /^(-|\+)?\d+\.?\d*$/;   //验证是否输入正确
    varValue = varValue.replace(/\s+/g, "");
    if (varValue != "") {
        if (!reDouble.test(varValue)) {
            alert("必需为数值！");
            obj.value = "";
            return false;
        }
        var textRealTotal = document.getElementById("textRealTotal").value.replace(/\s+/g, "");
        var txtDinJin = document.getElementById("txtDinJin").value.replace(/\s+/g, "");
        var txtUnpaid = document.getElementById("txtUnpaid").value.replace(/\s+/g, "");
        if (textRealTotal != "") {
            if (txtDinJin == "") {
                document.getElementById("txtUnpaid").value = textRealTotal;
            } else {
                document.getElementById("txtUnpaid").value = parseFloat(textRealTotal) - parseFloat(txtDinJin);
            }
        }
    }
}
//弹出订单选择
function GetEditOrder() {
    var url = "../../View/Order/OrderSelectList.aspx";
    window.open(url, "", "top=50px,left=50px,height=600px,width=800px");

}

//导出Word
function GetWord() {
    if ($("#hidRunState").val() == '1') {
        funMessage();
    } else {
        if (document.getElementById("hidStytle").value == "") {
            var tempValue = "";
            var checkValue = document.getElementsByName("checkBoxName");
            for (var i = 0; i < checkValue.length; i++) {
                if (checkValue[i].checked) {
                    tempValue = tempValue + checkValue[i].value + ",";
                }
            }
            document.getElementById("hidStytle").value = tempValue;
        }

        //  IsRuning = '1'
        __doPostBack("GetOrderWord", "");
        //document.getElementById("GetOrderWord").click();
        //  IsRuning = '0'
    }
}

//编辑时填充已经选择的风格
function FillStyle() {
    var styles = document.getElementById("hidStytle").value;

    styles = styles.split(",");
    for (var i = 0; i < styles.length; i++) {
        var varCheckBox = document.getElementById(styles[i]);
        if (varCheckBox != undefined) {
            varCheckBox.checked = true;
        }
    }
}

//编辑时填充已经选择的风格
function EditFillStyle(styles) {
    //var styles = document.getElementById("hidStytle").value;
    document.getElementById("hidStytle").value = styles;
    styles = styles.split(",");
    for (var i = 0; i < styles.length; i++) {
        var varCheckBox = document.getElementById(styles[i]);
        if (varCheckBox != undefined) {
            varCheckBox.checked = true;
        }
    }
}

//保存前获得选择的风格并保存前判断是否必选项目已经选择
function GetStyle(type) {
    if ($("#hidRunState").val() == '1') {
        funMessage();
    } else {
        $("#hidRunState").val('1');
        var dropDownList = document.getElementById("dropDate"); //获取年DropDownList控件 4
        if (dropDownList.options[dropDownList.selectedIndex].value == "") {
            alert("服务日期必须填写！");
            return false;
        } else {
            var varValue = document.getElementById("txtGROOM_NAME").value.replace(/\s+/g, "");
            if (varValue == "") {
                alert("客户姓名必须填写！");
                return false;
            } else {
                var tempValue = "";
                var checkValue = document.getElementsByName("checkBoxName");
                for (var i = 0; i < checkValue.length; i++) {
                    if (checkValue[i].checked) {
                        tempValue = tempValue + checkValue[i].value + ",";
                    }
                }
                document.getElementById("hidStytle").value = tempValue;
                var GetCValue = getCookieValue("shopcar");
                $.ajax({
                    type: "GET",
                    async: true,
                    url: "CheckProject.ashx?id=" + GetProjectID(GetCValue),
                    success: function (obj) {
                        if (obj != "") {
                            alert(obj);

                            if (type == "1") {
                                // __doPostBack("btn_Submit", "");
                                return true;
                            } else {
                                // __doPostBack("Button1", "");
                                return true;
                            }
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError)
                    { alert(thrownError); flag = true; return false; }
                });
            }
        }
    }
}
//选择订单后刷新购物车
function RefreshShopCar() {
    var varThis = $(".shopcar");
    getShopCar(varThis);

}
//订单移除项目
function RemoveProject(projectID) {
    if ($("#hidRunState").val() == '1') {
        funMessage();
    } else {
        deltr(projectID);
        $("#hidRunState").val('1');
        // document.getElementById("GetProject").click();

        __doPostBack("GetProject", "");
        // IsRuning = '0'
    }
}
//查询条件中点击弹出或者隐藏选项
function SearchMosOn(obj) {
    var hight = $(obj).position().top;
    $(obj).children("div").css("top", hight);
    $(obj).children("div").css("right", ($("#allsortlist").css("width")+4));
    $(obj).children("div").slideToggle(200);
}
//子页面获得查询条件
function getSearch(item) {
    $.ajax({
        type: "GET",
        async: false,
        url: "GetSearchItem.ashx?type=" + item,
        success: function (obj) {
            if (obj == "SessionTimeout") {
                IsReLogin();
            }
            else {
                $("#allsortlist").html(obj);
            }
            var var_withd = -($("#allsortlist").width()+4);
            $("#allsortlist").css("right", var_withd);
        },
        error: function (xhr, ajaxOptions, thrownError)
        { alert("网络异常，稍后重试！"); return false; }
    });
}
function showSearchItem() {
    // var varWindowWith;
    var obj = $('#allsortlist');
    //    if (typeof window.innerWidth != 'undefined') {
    //        varWindowWith = window.innerWidth; 
    //    }   // 支持其他浏览器
    //    else {
    //        varWindowWith = document.getElementsByTagName('body')[0].clientWidth;  
    //    }
    //    if (obj.html() == "") {
    //        obj.css("right", 0);
    //        getSearch($("#hidID").val());
    //       // $("#allsortlist").slideToggle(200);
    //    } 
    //else {
    // $("#allsortlist").slideToggle(200);
    // }
    //  var leftVale = obj.css();
    var rightValue = obj.css("right");
    var winWith = obj.width();
    var js;
    var temp = "-" + (winWith+4) + "px";
    if (rightValue == temp) {
        js = "+=" + winWith + "px";
        obj.animate({ right: js }, 350);
        $('.getsechitem').animate({ right: js }, 350);
    } else {
        js = "-=" + winWith + "px";
        obj.animate({ right: js }, 350);
        $('.getsechitem').animate({ right: js }, 350);
    }

}
//判断输入框是否输入整数
function checkIsInt(obj) {
    var value = obj.value.replace(/\s+/g, "");

    if (value == "") {
        alert("数量不能为空！");
    }
    if (isNaN(value)) {
        alert("只能输入整数");
        obj.value = "1";
    }
}
function OpenMatrial() {
    var varDate = $("#d12").val();
    var price = $("#dropPrice option:selected").val();
    var vURL = '../../SysManage/UniualMateral/ViewList.aspx?date=' + varDate + "&price=" + price;
    window.open(vURL, "", "top=150px,left=200px,height=600px,width=800px");
}

function msout(obj) {

    $(obj).css("border-color", "#C2C1B9");
}
function mson(obj) {
    $(obj).css("border-color", "#EEF2FB");
}
function changPagColour(obj) {
    var url = obj == "1" ? "../../Images/View/m1.png" : "../../Images/View/m2.png";
    $("#imagAdd").attr("src", url);
}
function changeJpagColor(obj) {
    var url = obj == "1" ? "../../Images/View/a1.png" : "../../Images/View/a2.png";
    $("#imagMinus").attr("src", url);
}


function createPosation(options, iputobj) {

    if ((options != undefined) && (options.inset != undefined)) {
        if (options.insetleft == undefined) { options.insetleft = options.inset; }
        if (options.insetright == undefined) { options.insetright = options.inset; }
        if (options.insettop == undefined) { options.insettop = options.inset; }
        if (options.insetbottom == undefined) { options.insetbottom = options.inset; }
    }

    // defaults
    options = $.extend({
        speed: 250,
        insetleft: 10,
        insetright: 10,
        insettop: 10,
        insetbottom: 10,
        borderColor: '#ffffff',
        borderType: "solid",
        outerClass: "ibe_outer",
        innerClass: "ibe_inner"
    }, options);

    // run plugin on entire jQuery set
    //    return this.each(function (i) {

    var 
  			$el = iputobj,
  			ibe_height = $el.outerHeight(),
			  ibe_width = $el.outerWidth();

    var 
			  wrapper = $("<div />", {
			      "class": options.outerClass,
			      "css": {
			          "width": ibe_width,
			          "height": ibe_height,
			          "overflow": "hidden",
			          "top": 0,
			          "left": 0,
			          "position": "relative"
			      },
			      "mouseenter": function () {
			          $el
    					 .next()
    					 .animate({
    					     "top": "-" + options.insettop + "px",
    					     "left": "-" + options.insetleft + "px",
    					     "height": ibe_height,
    					     "width": ibe_width,
    					     "opacity": 0.1
    					 }, {
    					     "duration": options.speed,
    					     "queue": false,
    					     "complete": function () {

    					         // BUG: for some reason this is getting called twice.

    					         // Kinda works... attempt at allowing selectability of main element
    					         // The problem is this only fires on complete but must make visibile on mouseleave no matter what
    					         // $el.next().css("visibility", "hidden");

    					     }
    					 });

			          // on mouseleave
			      },
			      "mouseleave": function () {

			          $el
  					     .next()
			          // .css({
			          //  "visibility": "visible"
			          // })
  						   .animate({
  						       "top": 0,
  						       "left": 0,
  						       "height": (ibe_height - (options.insettop + options.insetbottom)) + "px",
  						       "width": (ibe_width - (options.insetleft + options.insetright)) + "px",
  						       "opacity": 1
  						   }, {
  						       "duration": options.speed,
  						       "queue": false
  						   });

			      }
			  }),

			 after = $("<div />", {
			     "class": options.innerClass,
			     "css": {
			         "height": (ibe_height - (options.insettop + options.insetbottom)) + "px",
			         "width": (ibe_width - (options.insetleft + options.insetright)) + "px",
			         "border-left": options.insetleft + "px " + options.borderType + " " + options.borderColor,
			         "border-right": options.insetright + "px " + options.borderType + " " + options.borderColor,
			         "border-top": options.insettop + "px " + options.borderType + " " + options.borderColor,
			         "border-bottom": options.insetbottom + "px " + options.borderType + " " + options.borderColor,
			         "position": "relative",
			         "top": 0,
			         "left": 0
			     }
			 });

    $el.wrap(wrapper).after(after);

}

